import { Message } from 'element-ui'

//重写$message,默认展示关闭
const $message = options => {
  return Message({
    ...options,
    showClose: !options.noShowClose,
  })
}
;['success', 'warning', 'info', 'error'].forEach(type => {
  $message[type] = options => {
    if (typeof options === 'string') {
      options = {
        message: options,
        showClose: true,
      }
    }
    options.type = type
    return Message(options)
  }
})
export default $message
